package xin.nick;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Optional;

/**
 * @author Nick
 * @since 2024/4/12
 */

@SpringBootApplication
@Slf4j
public class DemoServiceApplication {

    @SneakyThrows
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(DemoServiceApplication.class, args);

        ConfigurableEnvironment environment = applicationContext.getEnvironment();

        log.info("DemoServiceApplication started!!!");
        log.info("DemoServiceApplication 启动!!!");


        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = Optional.ofNullable(environment.getProperty("server.port")).orElse("8080");
        String contextPath = Optional.ofNullable(environment.getProperty("server.servlet.context-path")).orElse("");
        log.info("http://{}:{}{}/doc.html", ip, port, contextPath);

    }

}
